﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace snat.model {
    public class MessageWindowedNode : WindowedNode {
        public event windowDelegate NewWindow;

        /// <summary>
        /// Window size, DEFAULT : 1
        /// </summary>
        public static int WindowSize { get; private set; }
        private static int WindowCount;
        private static object registrationLock = new object();
        private static bool registered = false;

        public MessageWindowedNode(int _id, string _name)
            : base(_id, _name) {
                lock (registrationLock) {
                    if (!registered) {
                        MessageWindowedNode.WindowSize = 100;
                        registered = true;
                    }
                }

        }

        protected override void OnMessageProcessed(Message m) {
            if (WindowCount > WindowSize) {
                WindowCount = 0;
                TriggerOverlayReset();
                NewWindow();
            }
        }

    }
}
